package com.onesports.intelligent.k12.polarlight.controller.wx.map;

import java.util.List;

import javax.validation.constraints.NotBlank;

import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.onesports.intelligent.k12.polarlight.common.utils.ResultUtil;
import com.onesports.intelligent.k12.polarlight.constant.ApiPathConstants;
import com.onesports.intelligent.k12.polarlight.domain.vo.organization.CampusSearchVO;
import com.onesports.intelligent.k12.polarlight.service.campus.OrganizationCampusService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;

/**
 *  地图控制器
 * @author clw
 */
@RequiredArgsConstructor
@RestController
@RequestMapping(ApiPathConstants.MAP)
@Api(tags = "会员端-地图API")
@PreAuthorize("hasAuthority('MINI_APP')")
public class MapController {

    private final OrganizationCampusService organizationCampusService;

    @GetMapping("/campus-list")
    @ApiOperation(value = "校区列表", response = CampusSearchVO.class)
    public ResponseEntity<List<CampusSearchVO>> campusList(){

        List<CampusSearchVO> list = organizationCampusService.getCampusList();
        return ResultUtil.success(list);
    }

    @GetMapping("/area-campus-list")
    @ApiOperation(value = "根据区域code查找校区位置和数量", response = CampusSearchVO.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "areaCode", value = "区域code", required = true, dataType = "string", paramType = "query")
    })
    public ResponseEntity<List<CampusSearchVO>> campusSearchList(@NotBlank(message = "区域code不可为空") String areaCode){

        List<CampusSearchVO> list = organizationCampusService.getAreaCampusList(areaCode);
        return ResultUtil.success(list);
    }

}
